package com.zhangfei.stream;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 过滤：满足条件的留下来,filter——接收 Lambda ， 从流中排除某些元素。
 */
public class FilterTest {
    public static void main(String[] args) {
        //初始化学生数据并转成list
        List<Student> students = Arrays.asList(
                new Student(1, "张三", 25),
                new Student(1, "李四", 32),
                new Student(1, "王五", 18),
                new Student(1, "赵六", 29));
        filterStudentByAge(students);
    }


    public static void filterStudentByAge(List<Student> students) {
        List<Student> studentList = students.stream()
                .filter((e) -> {
                    //(中间操作)所有的中间操作不会做任何的处理
                    System.out.println("开始过滤");
                    return e.getAge() >= 30;
                }).collect(Collectors.toList());
        System.out.println(studentList);

    }
}
